package algorithms.leaning.class02;

import common.util.MyUtil;

/**
 * 如何不用额外变量交换两个数
 *
 * @author guichang
 * @date 2021/5/30
 */

@SuppressWarnings("all")
public class Code1_异或_交换 {

    public static void main(String[] args) {
        int a = 1, b = 2;
        MyUtil.printf("交换前：a={}, b={}", a, b);
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
        MyUtil.printf("交换后：a={}, b={}", a, b);
    }


}